package com.webchat.Utils;

import org.hibernate.SessionFactory;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;

/**
 * Created by YongX on 2016/8/20.
 */
public class HibernateUtil {
    private static final SessionFactory sessionFactory = setSessionFactory();

    private static SessionFactory setSessionFactory(){
        final StandardServiceRegistry registry =
                new StandardServiceRegistryBuilder().configure().build();
        return new MetadataSources(registry).buildMetadata().buildSessionFactory();
    }

    public static SessionFactory getSessionFactory(){
        return  sessionFactory;
    }
}
